﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PSE.Deployment.Engine.Enums;
using PSE.Deployment.Engine.CustomEventArgs;

namespace PSE.Deployment.Engine.Interfaces
{
    public interface IStep
    {
        string Id { get; set; }
        string Description { get; set; }

        /// <summary>
        /// Indica que se o Engine irá ou não realizar o salvamento dos parâmetros 
        /// </summary>
        //bool SaveParametersOnFinished { get; set; }
        /// <summary>
        /// Indica que em caso de erros no passo, o mesmo será re-executado um numero configurado de vezes
        /// </summary>
        bool AutomaticRetryOnError { get; set; }
        /// <summary>
        /// Numero de tentativas de re-execução de um passo em caso de erros
        /// </summary>
        int MaxAttempts { get; set; }
        /// <summary>
        /// Número de tempo de espera para a re-execução de um passo em caso de erros
        /// </summary>
        int RetryMillisecondsTimeout { get; set; }

        bool Ignorable { get; set; }

        IStepGroup Parent { get; set; }

        StepErrorBehavior ErrorBehavior { get; set; }

        StepNavigationBehavior NavigationBehavior { get; set; }

        StepExecutionStatus ExecutionStatus { get; set; }

        Exception ExecutionException { get; set; }
        Exception UndoException { get; set; }

        int CurrentProgress { get; }
        int MaximumProgress { get; }
        string ProgressDescription { get; }

        void Execute();
        void Undo();

        event EventHandler<ExecutionStartedEventArgs> ExecutionStarted;
        event EventHandler<ExecutionFinishedEventArgs> ExecutionFinished;
        event EventHandler<ExecutionErrorEventArgs> ExecutionError;
        event EventHandler<ExecutionIgnoredEventArgs> ExecutionIgnored;
        
        event EventHandler<ExecutionProgressEventArgs> ExecutionProgress;
        
        event EventHandler<UndoStartedEventArgs> UndoStarted;
        event EventHandler<UndoFinishedEventArgs> UndoFinished;
        event EventHandler<UndoErrorEventArgs> UndoError;

        void OnExecutionStarted(ExecutionStartedEventArgs e);
        void OnExecutionStarted(object sender, ExecutionStartedEventArgs e);
        void OnExecutionFinished(ExecutionFinishedEventArgs e);
        void OnExecutionFinished(object sender, ExecutionFinishedEventArgs e);
        void OnExecutionError(ExecutionErrorEventArgs e);
        void OnExecutionError(object sender, ExecutionErrorEventArgs e);
        void OnExecutionIgnored(ExecutionIgnoredEventArgs e);
        void OnExecutionIgnored(object sender, ExecutionIgnoredEventArgs e);

        void OnUndoStarted(UndoStartedEventArgs e);
        void OnUndoFinished(UndoFinishedEventArgs e);
        void OnUndoError(UndoErrorEventArgs e);
        void OnUndoError(object sender, UndoErrorEventArgs e);
    }
}
